﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using SmsUI.DataBase;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace SmsUI
{
    public class ConfigManager
    {
        public static string GetValue(string key)
        {
            try
            {
                DataBase.smsdbDataSet.tb_ConfigDataTable tbConfig = DbRules.Instance.GetConfigInfo();
                foreach (smsdbDataSet.tb_ConfigRow row in tbConfig)
                {
                    if (row.Para == key)
                    {
                        return row.Value;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                throw;
            }
            return "";

        }
        public static void SetValue(string key, string value)
        {

            DataBase.smsdbDataSet.tb_ConfigDataTable tbConfig = DbRules.Instance.GetConfigInfo();
            foreach (smsdbDataSet.tb_ConfigRow row in tbConfig)
            {
                if (row.Para == key)
                {
                    row.Value = value;
                    break;
                }
            }
            DbRules.Instance.UpdateConfigInfo();
            tbConfig.AcceptChanges();
        }
        public static int SetType { get; set; }

    }
}
